//
//  SettingViewController.m
//  F50
//
//  Created by 郝 巍 on 15/5/12.
//  Copyright (c) 2015年 ZACK. All rights reserved.
//

#import "SettingViewController.h"
#import "LoginViewController.h"
#import "DealViewController.h"
@interface SettingViewController ()

@end

@implementation SettingViewController

- (void)createBackground
{
    self.navigationController.navigationBarHidden = YES;
    UIImageView *bgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
    bgView.image = [UIImage imageNamed:@"background"];
    bgView.userInteractionEnabled = YES;
    [self.view addSubview:bgView];
    
    //中间标题
    UILabel *  nav_title=[[UILabel alloc] initWithFrame:CGRectMake(WIDTH/2 - 80, 20, 160, 40)];
    nav_title.text=@"设置";
    nav_title.textAlignment = NSTextAlignmentCenter;
    nav_title.font=[UIFont boldSystemFontOfSize:20];
    nav_title.textColor=[UIColor whiteColor];
    nav_title.backgroundColor=[UIColor clearColor];
    [bgView addSubview:nav_title];
    
    UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    backBtn.frame = CGRectMake(20, 32, 15, 18);
    [backBtn setBackgroundImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    [backBtn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    [bgView addSubview:backBtn];
    
    UIImageView *f50 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 165*imageW, 95*imageW)];
    f50.center = CGPointMake(WIDTH/2, 70 + 165*imageW/2);
    f50.image = [UIImage imageNamed:@"f50"];
    [bgView addSubview:f50];
    
    UIButton *outBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    outBtn.frame = CGRectMake(WIDTH/2 - 150, 90 + 165*imageW, 300, 45);
    [outBtn setTitle:@"退出登录" forState:UIControlStateNormal];
    [outBtn setBackgroundImage:[UIImage imageNamed:@"out"] forState:UIControlStateNormal];
    [outBtn addTarget:self action:@selector(outLogin) forControlEvents:UIControlEventTouchUpInside];
    [bgView addSubview:outBtn];
    
    
    
    
    UIButton *dealBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    dealBtn.frame = CGRectMake(15, 150 + 165*imageW, WIDTH - 30, 20);
    [dealBtn addTarget:self action:@selector(readDeal) forControlEvents:UIControlEventTouchUpInside];
    [dealBtn setTitle:@"F50 season5 服务协议" forState:UIControlStateNormal];
    [dealBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    dealBtn.titleLabel.font = [UIFont systemFontOfSize:13];
    [bgView addSubview:dealBtn];
    
    
    UILabel *wordLab = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH/2 - 150, dealBtn.frame.origin.y +  30, 300, 20)];
    wordLab.text = @"点击上面的“登录”按钮，即表示你同意";
    wordLab.textAlignment = NSTextAlignmentCenter;
    wordLab.font = [UIFont systemFontOfSize:13];
    wordLab.textColor = RGB(158, 158, 158);
    [bgView addSubview:wordLab];

    
}
- (void)viewWillAppear:(BOOL)animated{
    self.tabBarController.tabBar.hidden = NO;

}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self createBackground];

}

-(void)readDeal{
    DealViewController *deal = [[DealViewController alloc]init];
    [self.navigationController pushViewController:deal animated:YES];
}


- (void)back{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)outLogin{
    [USER_DEFAULT setObject:@"" forKey:@"phone"];
    LoginViewController *login = [[LoginViewController alloc]init];
    
    [self.navigationController pushViewController:login animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
